package com.jwaoo.chat.session.actions;

import com.dx.as.common.sys.NetworkUtil;
import com.jwaoo.chat.Message;
import com.jwaoo.chat.R;
import com.jwaoo.chat.attachment.FileAttachment;
import com.jwaoo.chat.data.db.MessageHandler;
import com.jwaoo.chat.session.avchat.AVChatState;
import com.jwaoo.chat.session.avchat.AVChatType;
import com.jwaoo.chat.session.avchat.FloatView;

/**
 * Created by jwaoo on 2017/10/23.
 */

public class VoiceChatAction extends BaseAction{

    public VoiceChatAction() {
        super(R.drawable.dialogue_more_chat_btn,
                R.string.input_panel_audio_call);
    }

    @Override
    public void onClick() {
        if (FloatView.getInstance().isStart()) return;
        if (NetworkUtil.isNetAvailable(getActivity())) {
            startAudioVideoCall(AVChatType.AUDIO);
        } else {
            getContainer().proxy.showError(R.string.network_is_not_available);
        }
    }

    /************************ 音视频通话 ***********************/

    public void startAudioVideoCall(AVChatType avChatType) {
        FileAttachment fileAttachment = new FileAttachment();
        fileAttachment.setAttachstate(AVChatState.request.getValue());
        fileAttachment.setRoomid("");
        Message message = MessageHandler.getInstace(getActivity()).createMessage(avChatType.getValue(),getAccount(),fileAttachment);
        FloatView.getInstance().launch(message);
    }
}
